<%@ include file="/common/taglibs.jsp"%>
<%!//This page control use recent view or not, and the layout. But the data is processed in recentView.html request, which will use cookie and can be staticalized.%>

<c:if test="${applicationScope.appConfig.isRecentViewEnabled}">
	<div class="product_arrange_01" style="display:none;" id="recentView">
		<div class="top clearfix"><h3><fmt:message key="recentView.title" /></h3><a href="javascript:void(0)" onclick="clearRecentView()"><fmt:message key="recentView.clear"/></a></div>
		<div class="content">
			<ul  id="recentProductDiv" class="items">
				
			</ul>
		</div>
	</div>
</c:if>


<script type="text/javascript" src="${ctxPath}/scripts/probiz/framework/recentView.js?rs=${appConfig.rs}"></script>
<script type="text/javascript">
<%--插入cookie前必须执行escape函数进行编码，获取cookie的属性可用unescape反编码 --%>

$j(document).ready(function () {
	if (navigator.cookieEnabled) {
		renderRecentViewProducts();
		
		var parentUrl = document.URL;
		var pattern = new RegExp("/item[1-9][0-9]*.html");   
		if (pattern.test(parentUrl)) {
			var imgSrc = $("_imgSrc").value!=""?escape($("_imgSrc").value):"none";
			var url=escape(document.URL);
			var productId = escape($("_productId").value)+"p";		
			var title = escape($("_title").value);		
			var price = escape($("_price").value);		
			addRecentViewItem([productId,url,title,imgSrc,price]);
		} 
	}
});



//填充recentView
function renderRecentViewProducts() {
	var itemAttrArray = getRecentViewItemArray();
	var html = "";
	if (itemAttrArray && itemAttrArray.length > 0) {
		for (var i = 0; i < itemAttrArray.length; i++) {
			var attrArray = itemAttrArray[i];	
			html += '<li>';
			html += '<a href="'+unescape(attrArray[1])+'" class="img"><img src="'+unescape(attrArray[3])+'" width="58" height="58" onerror="this.src=__defaultImage_s0;this.onerror=\'\';"/></a>';
			html += '<a href="'+unescape(attrArray[1])+'" class="txt">'+unescape(attrArray[2])+'</a>';
			html += '<b>'+'${appConfig.defaultCurrencySymbol}'+attrArray[4]+'</b>';
			html += '</li>';
		}
		$j('#recentProductDiv').html(html);
		$j('#recentView').show();
	}
}

</script>